import com.fz.entity.Book;
import com.fz.spring.Hello;
import javafx.scene.chart.PieChart;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by webrx on 2017/7/1.
 */
public class Dom {
    protected BeanFactory factory;
    @Before
    public void init(){
        this.factory=new ClassPathXmlApplicationContext("beans.xml");

    }
    @Test
    public void test02(){
        Hello h01 =this.factory.getBean("hz05" ,Hello.class);
       /* h01.show02();
        h01.showBook();

        System.out.println(h01.getBks());
        for(Book b : h01.getBks()){
            System.out.println(b.getName());
        }*/
        System.out.println(h01.getAddr().length);
        for(Book ss: h01.getAddr()){
            System.out.println(ss.getName());
        }
    }


    @Test
    public void show(){
        BeanFactory factory = new ClassPathXmlApplicationContext("beans.xml");
        Hello hh =factory.getBean("h",Hello.class);
        System.out.println(hh.show(9));



        Date  ad=factory.getBean("d",Date.class);
        String ss =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ad);
        System.out.println(ss);
    }
    @Test
    public void date(){
        SimpleDateFormat y = this.factory.getBean( "sfg02",SimpleDateFormat.class);
            Date dd = this.factory.getBean("d",Date.class);

        System.out.println(y.format(dd));

    }
}
